package com.diy.sigmund.diycommon.spring.anno;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * <br>参数校验注解，入参为空也会校验，参数校验优先级按定义的注解从先到后
 * <br>1、不传入参或者传null：{"timestamp":"2021-11-05T09:58:29.497+00:00","status":400,"error":"Bad Request","message":"Required request body is missing: public com.diy.sigmund.diycommon.entity.ResultMsg com.diy.sigmund.diyorder.controller.SecKillController.panicBuying(com.diy.sigmund.diyorder.entity.dto.OdSeckillOrderDTO)","path":"/order/secKill/panicBuying"}
 * <br>2、传{}，{"code":"500","msg":"handleVerifyParam error","data":null}
 *
 * @author ylm-sigmund
 * @since 2021/5/24 21:45
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface VerifyParams {

    /**
     * 放置在controller上，提供入参校验，需配合注解@RequestBody
     *
     * @VerifyParams(verifyParams = {@VerifyParam(fieldName = "id"),
     * @VerifyParam(fieldName = "name", verifyPolicy = VerifyParamPolicyEnum.NOT_BLANK, msg = "name不能为null啊啊啊啊啊嗄！！！！！"),
     * @VerifyParam(fieldName = "phone", verifyPolicy = VerifyParamPolicyEnum.MATCHES, verifyValue = VerifyParamUtil.PHONE_PATTERN),
     * @VerifyParam(fieldName = "email", verifyPolicy = VerifyParamPolicyEnum.MATCHES, verifyValue = VerifyParamUtil.EMAIL_PATTERN),
     * @VerifyParam(fieldName = "idCard", verifyPolicy = VerifyParamPolicyEnum.MATCHES, verifyValue = VerifyParamUtil.IDCARD_PATTERN),
     * @VerifyParam(fieldName = "aBoolean", verifyPolicy = VerifyParamPolicyEnum.ASSERTTRUE),
     * @VerifyParam(fieldName = "minInteger", verifyPolicy = VerifyParamPolicyEnum.MIN, verifyValue = "100"),
     * @VerifyParam(fieldName = "maxInteger", verifyPolicy = VerifyParamPolicyEnum.MAX, verifyValue = "100"),
     * @VerifyParam(fieldName = "betweenInteger", verifyPolicy = VerifyParamPolicyEnum.BETWEENINTEGER, verifyValue = "50,100"),
     * @VerifyParam(fieldName = "pastDate", verifyPolicy = VerifyParamPolicyEnum.PAST, verifyValue = "2021-6-27 18:09:00"),
     * @VerifyParam(fieldName = "futureDate", verifyPolicy = VerifyParamPolicyEnum.FUTURE, verifyValue = "2021-6-27 18:09:00"),
     * @VerifyParam(fieldName = "betweenDate", verifyPolicy = VerifyParamPolicyEnum.BETWEENDATE, verifyValue = "2021-6-27 18:09:00,2021-6-27 23:09:00")})
     */
    VerifyParam[] value();

}
